import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static String myPrint(double n, int t1) {
        String s = "%." + String.valueOf(t1) + "f";
        return String.format(s, n);
    }

    public static String myPrint(double n, int t1, int t2) {
        String s = "%" + String.valueOf(t1) + "." + String.valueOf(t2) + "f";
        return String.format(s, n);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = 10;
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        int minValue = Integer.MAX_VALUE;
        int minIndex = -1;
        for (int i = 0; i < n; i++) {
            if (minValue > nums[i]) {
                minValue = nums[i];
                minIndex = i;
            }
        }
        nums[minIndex] = nums[0];
        nums[0] = minValue;
        int maxValue = Integer.MIN_VALUE;
        int maxIndex = -1;
        for (int i = 0; i < n; i++) {
            if (maxValue < nums[i]) {
                maxValue = nums[i];
                maxIndex = i;
            }
        }
        nums[maxIndex] = nums[n - 1];
        nums[n - 1] = maxValue;
        for (int i = 0; i < n; i++) {
            System.out.print(nums[i] + " ");
        }
    }
}